
<%@page import="com.lovo.vo.TreeNode"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<TreeNode> list = (List<TreeNode>)request.getAttribute("list");

%>

<%!
	public String getsons(TreeNode root){
	String result = " ";
	if(root.getChildren().size()>0){
		result = result + "<ul>";
		for(TreeNode son:root.getChildren()){
			result = result+"<li>";
			result = result+"<a href=\"javascript:void(0);\"><span style='display:none'>"+son.getId()+"</span><span>"+son.getText()+"</span></a>";
			result = result + getsons(son);
			result = result+"</li>";
		}
		result = result + "</ul>";
	}
	return result;
	}

%>

<script type="text/javascript">
	$(document).ready(function(){
		$("#aul a").click(function(){
		
			var id = $(this).children().first().text();
			$("#id").val(id);
			$("#add").attr("href","<%=basePath%>menu/addpop.do?id="+id+"");
			$("#delete").attr("href","<%=basePath%>menu/del.do?id="+id+"");
			$("#update1").css({visibility:"hidden"});
			$("#update2").css({visibility:"visible"});
			$("#update2").attr("href","<%=basePath%>menu/updatepop.do?id="+id+"");
			
			
		});
		
	});

	</script>
 <div class="pageHeader">
	<form onsubmit="return navTabSearch(this);" action="<%=basePath%>dept/getadd.do" method="post" id="deptform" >
	<input type="hidden" name="id" id="id"/>
	<div class="pageContent" id="treepage">
	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="add" href="<%=basePath%>menu/addpop.do" target="dialog" mask="true" title="新增菜单信息" id="add"><span>添加</span></a></li>
			<li><a class="delete" href="<%=basePath%>menu/del.do" target="ajaxTodo" title="确定要删除吗?" id="delete"><span>删除</span></a></li>
			<li>
				<a class="edit" href="javascript:void(0)"  id="update1" style="color:gray"><span>修改</span></a>
				<a class="edit" href="<%=basePath%>menu/updatepop.do"   target="dialog" mask="true" title="修改菜单信息" id="update2" style="visibility:hidden;position:relative;left:-47px;"><span>修改</span></a>
			
			</li>
			<li class="line">line</li>
		</ul>
	</div>

 </div>
	</form>
</div>

<div style="float:left; display:block; margin:10px; overflow:auto; width:90%; height:80%; border:solid 1px #CCC; line-height:21px; background:#FFF;">
<%
	for(TreeNode root:list){
	%>
<ul class="tree treeFolder collapse" id="aul">
	<li><a href="javascript:void(0);" ><span style='display:none'><%= root.getId()%></span><span><%= root.getText()%></span></a>
	<%
		out.write(getsons(root));
	%>
	</li>
</ul>
<%
		}
	%>

</div>
  